package cn.mw.cmdb.entity;

import cn.mw.cmdb.util.DataCreateInfo;
import cn.mw.components.mongodb.anno.AutoId;
import cn.mw.components.mongodb.anno.CMDBProperty;
import cn.mw.scanengine.snmp.scan.model.IfStatus;
import cn.mw.scanengine.snmp.scan.model.IfType;
import cn.mw.scanengine.snmp.scan.model.PortType;
import cn.mw.scanengine.view.DeviceInterfaceInfoAware;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.javers.core.metamodel.annotation.DiffIgnore;
import org.javers.core.metamodel.annotation.Id;
import org.javers.core.metamodel.annotation.IgnoreDeclaredProperties;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;
import java.util.Objects;

@Document("mw_cmdbmd_assets_interface")
@Data
public class AssetsInterfaceDTO implements DataCreateInfo , DeviceInterfaceInfoAware {

    // ID字段
    @CMDBProperty(searchType = PropertyTypeString.ID, searchPrefix = "_")
    @AutoId
    @Schema(description = "id")
    @DiffIgnore
    private String id;

    @Schema(description = "实例ID")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    @Id//javers版本比较id
    private String instanceId;

    @Schema(description = "接口索引")
    @CMDBProperty(searchType = PropertyTypeInt.ID)
    @Id//javers版本比较id
    private Integer ifIndex;

    @Schema(description = "原始接口名称")
    @CMDBProperty(searchType = PropertyTypeString.ID ,keywordSearch = true)
    private String name;


    @Schema(description = "转换后的接口名称")
    @CMDBProperty(searchType = PropertyTypeString.ID ,keywordSearch = true)
    private String convertName;

    @Schema(description = "接口别名")
    @CMDBProperty(searchType = PropertyTypeString.ID ,keywordSearch = true)
    private String alias;

    @Schema(description = "接口类型")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private IfType type;

    @Schema(description = "接口状态")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private IfStatus state;

    @Schema(description = "接口描述")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String description;

    @Schema(description = "接口mac")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String mac;

    @Schema(description = "接口MTU")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private Integer mtu;

    @Schema(description = "接口IP")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String ip;

    @Schema(description = "接口子网掩码")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String subnetMask;

    @Schema(description = "接口模式(TRUNK、ACCESS、HYBIRD)")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String ifMode;

    @Schema(description = "access-->vlan tag(数字)；trunk --> trunk")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String vlan;

    @Schema(description = "vlan标志(true为虚拟接口，false为物理口)")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private Boolean vlanFlag;

    @Schema(description = "光口或者电口")
    @CMDBProperty
    private PortType portType;

    @Schema(description = "是否显示")
    @CMDBProperty(searchType = PropertyTypeSwitch.ID)
    @DiffIgnore
    private Boolean showFlag;

    @Schema(description = "是否告警")
    @CMDBProperty(searchType = PropertyTypeSwitch.ID)
    @DiffIgnore
    private Boolean alertFlag;

    @Schema(description = "是否监控")
    @CMDBProperty(searchType = PropertyTypeSwitch.ID)
    @DiffIgnore
    private Boolean itemFlag;


    @Schema(description = "是否修改")
    @CMDBProperty(searchType = PropertyTypeInt.ID)
    @DiffIgnore
    private Boolean editorFlag;

    @Schema(description = "vrf")
    @CMDBProperty(searchType = PropertyTypeString.ID)
    private String vrf;

    @DiffIgnore
    private Long creater;

    @DiffIgnore
    private Date createTime;

    @DiffIgnore
    private Long modifier;

    @DiffIgnore
    private Date modificationTime;

    @Override
    public Date getCreateTime() {
        return createTime;
    }

    @Override
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public Long getCreater() {
        return creater;
    }

    @Override
    public void setCreater(Long creater) {
        this.creater = creater;
    }

    @Override
    public Date getModificationTime() {
        return modificationTime;
    }

    @Override
    public void setModificationTime(Date modificationTime) {
        this.modificationTime = modificationTime;
    }

    @Override
    public void setModifier(Long modifier) {
        this.modifier = modifier;
    }

    @Override
    public Long getModifier() {
        return modifier;
    }
}
